package com.woniuxy.kaer.service.controller;


import cn.hutool.core.bean.BeanUtil;
import com.woniuxy.kaer.commons.util.Result;
import com.woniuxy.kaer.service.entity.ServiceProcesses;
import com.woniuxy.kaer.service.from.UpdateServiceProcessesFrom;
import com.woniuxy.kaer.service.param.UpdateServiceProcessesParam;
import com.woniuxy.kaer.service.service.ServiceProcessesService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.ibatis.annotations.Update;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author 程诗洋
 * @since 2025年02月17日
 */
@RestController
@RequestMapping("/serviceProcesses")
@Api(tags = "订单服务项目流程类")
public class ServiceProcessesController {
    @Resource
    private ServiceProcessesService serviceProcessesService;
    //工作人员确认订单中服务项目的状态
    @PutMapping("/updateServiceProcesses")
    @ApiOperation("订单服务项目流程更改接口")
    public Result updateServiceProcesses(@RequestBody UpdateServiceProcessesFrom from)throws Exception{
        UpdateServiceProcessesParam updateServiceProcessesParam = BeanUtil.toBean(from, UpdateServiceProcessesParam.class);
        serviceProcessesService.updateServiceProcesses(updateServiceProcessesParam);
        return Result.succeed("完成服务项目（其中一个）",null);
    }
    //查询当前订单下面的服务项目流程
    @GetMapping("/getServiceProcessesByServiceOrderId")
    public Result getServiceProcessesByServiceOrderId(String serviceOrderId)throws Exception{
        List<ServiceProcesses> serviceProcesses =serviceProcessesService.getServiceProcessesByServiceOrderId(serviceOrderId);
        return Result.succeed("查询成功",serviceProcesses);
    }
}

